package com.hiyee.service;

import com.github.pagehelper.PageInfo;
import com.hiyee.utils.PagedGridResult;

import java.util.List;

/**
 * 基础 service 类
 *
 * @author WangBin
 */
public class BaseService {
    /**
     * 统一返回列表分页格式
     *
     * @param dataList
     * @param page
     * @param pageSize
     * @return
     */
    protected PagedGridResult getPageResult(List<?> dataList, Integer page, Integer pageSize)
    {
        PageInfo<?> pageInfo = new PageInfo<>(dataList);
        PagedGridResult pagedGridResult = new PagedGridResult();
        pagedGridResult.setPage(page);
        pagedGridResult.setRows(dataList);
        pagedGridResult.setRecords(pageInfo.getPages());
        pagedGridResult.setTotal(pageInfo.getTotal());
        return pagedGridResult;
    }
}
